﻿using System;
using System.Collections.Generic;
using System.Data.Linq;
using System.Linq;
using System.Text;
using InfoTech.Core.Service;
using InfoTech.LanTranh.MucVu.Bussiness;
using InfoTech.Mvc.LanTranh.MucVu.Models;

namespace InfoTech.LanTranh.MucVu.Service
{
    public class USERService : BaseService
    {
        public static bool Check_Insert_USER(USER user)
        {
            bool result = true;
            DataContext dataContext = CreateDataContext();
            result &= dataContext.GetTable<USER>().FirstOrDefault(c => c.USERNAME.ToUpper() == user.USERNAME.ToUpper()) == null;
            return result;
        }

        public static bool Check_Update_USER(USERModel user)
        {
            bool result = true;
            DataContext dataContext = CreateDataContext();
            result &= dataContext.GetTable<USER>().FirstOrDefault(c => c.USERNAME.ToUpper() == user.USERNAME.ToUpper() && c.USERID != user.USERID) == null;
            result &= dataContext.GetTable<USER>().FirstOrDefault(c => c.PASSWORD == user.OLD_PASWORD && c.USERID == user.USERID) != null;
            return result;
        }

        public static bool Check_Delete_USER(string[] strings)
        {
            return true;
        }
    }
}
